package myPack;

import java.util.Vector;

import javax.swing.table.AbstractTableModel;

class MyTableModel extends AbstractTableModel {
    private String[] columnNames = {"Titel", "Interpreter", "Dateiname", "MD5 Hash"};
    private Vector<Vector<Object>> data = new Vector<Vector<Object>>();

    public int getColumnCount() {
        return columnNames.length;
    }

    public int getRowCount() {
        return data.size();
    }

    public String getColumnName(int col) {
        return columnNames[col];
    }

    public Object getValueAt(int row, int col) {
        return data.elementAt(row).elementAt(col);
    }

    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }

    /*
     * Don't need to implement this method unless your table's
     * editable.
     */
    public boolean isCellEditable(int row, int col) {
        //Note that the data/cell address is constant,
        //no matter where the cell appears onscreen.
        /*if (false) {
            return false;
        } else {
            return true;
        }*/
    	return true;
    }

    /*
     * Don't need to implement this method unless your table's
     * data can change.
     */
    public void setValueAt(Object value, int row, int col) {
    	data.elementAt(row).setElementAt(value, col);
        fireTableCellUpdated(row, col);
    }
    
    public void addRow(Song song) {
    	this.data.add(song.getVector());	
    }
    
}
